#ifndef XPMDOC_DAL_SIGN_JSON_ACCESS_H
#define XPMDOC_DAL_SIGN_JSON_ACCESS_H
#include <string>
#include "model/XpmTermDoc.h"
#include "libjson.h"


namespace conex {
	class TermControl;
}

class JSONNode;
namespace xpm {
	using namespace std;
	
	class SignJson {
	public:
		SignJson(conex::TermControl* termControl):  _termControl(termControl) {Init();}
		void Init();
		SignJson(char* filename, char* schemaname, string outfile = "out.xml") 
			:  m_filename(filename), _outfile(outfile) { Init();}
		virtual ~SignJson();
		virtual wstring Load(XpmTermDoc& voc);
		virtual int Load(XpmTermDoc& voc, wstring signs);
		virtual bool Save(XpmTermDoc& voc, wstring& syntax);
		void SetFilename(const char* filename);
		string GetFilename();
		bool SaveAs(XpmTermDoc& voc, const char* filename, wstring& syntax);
		bool SaveAsPureJson(XpmTermDoc& voc, const char* filename, wstring& syntax);
		void SetTermControl(conex::TermControl* termControl);
		conex::TermControl* termControl();
		//parse the xml document with schema, return the true of false
		//serilizae xml 
		//parses
		wstring ParseWithJson(const char* filename, XpmTermDoc& voc);
		void ParseSignsBlocks(JSONNode n, XpmTermDoc& voc);
		void ParseSigns(JSONNode n, XpmTermBlock* block);
	private:
		conex::TermControl* _termControl;
		string m_filename;
		string _outfile;
	};

	inline void SignJson::SetFilename(const char* filename) {
		m_filename = filename;
	}

	inline string SignJson::GetFilename() {
		return m_filename;
	}

	inline void SignJson::SetTermControl(conex::TermControl* termControl) {
		_termControl = termControl;
	}
	inline conex::TermControl* SignJson::termControl() {
		return _termControl;
	}
}
#endif